<form action="index.php?option=com_question" method="post" class="adminform" name="adminForm" id="adminForm" class="form-validate">

     <table style="width: 100%;" border=0 >
        <tr style="visibility:hidden">
            <td style="width:125px"></td>
            <td style="width:520px"></td>
            <td style="width:630px"></td>
        </tr>
        <tr>

            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">質問ID</td>

            <td style=";font-size: 1.091em">

                <label><?php echo $this->row->QUES_CODE;?></label>

                <input name="jform[QUES_CODE]" type="hidden" value="<?php echo $this->row->QUES_CODE;?>" />

            </td>

            <td><span style="color: red;font-size: small;font-family: 'ＭＳ Ｐゴシック', Osaka;text-align: left;">※印は入力必須項目です。</span></td>

        </tr>

        <tr>

            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">質問 <span style="color: red;font-size: small;font-family: 'ＭＳ Ｐゴシック', Osaka;">※</span></td>

            <td colspan="2">

                <textarea cols="70" rows="6" name="jform[QUES_TITLE]"><?php echo $this->row->QUES_TITLE;?></textarea>

            </td>

        </tr>

        <tr>

            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">アンケート名<span style="color: red;font-size: small;font-family: 'ＭＳ Ｐゴシック', Osaka;">※</span></td>

            <td colspan="2">

                <select name="jform[QUES_SERQ_CODE]" id="serq" class="big">

                    <option value='0'>アンケート名</option>    

                    <?php 

                        foreach($this->getModel()->getSERQ_FULLDOWN() as $serq){

                            $selected = $this->row->QUES_SERQ_CODE == $serq->SERQ_CODE ? 'selected' : '';

                            echo "<option $selected value='$serq->SERQ_CODE'>$serq->SERQ_TITLE</option>";

                        }

                     ?>    

                </select>

            </td>			

        </tr>

        <tr>

            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">ページ名<span style="color: red;font-size: small;font-family: 'ＭＳ Ｐゴシック', Osaka;">※</span></td>

            <td colspan="2">

                 <select id="pagq" name="jform[QUES_PAGQ_CODE]" class="big">

                    <option value="0">ページ名 </option>

                    <?php 

                        $model = $this->getModel();

                        $this->pagq = &$model->getPAGQ_FULLDOWN($this->row->QUES_PAGQ_CODE);

                        foreach($this->pagq as $pagq){

                            $selected = $this->row->QUES_PAGQ_CODE == $pagq->PAGQ_CODE ? 'selected' : '';

                            echo "<option $selected value='$pagq->PAGQ_CODE'>$pagq->PAGQ_TITLE</option>";

                        }

                     ?>  

                 </select>    

            </td>

        </tr>

        <tr>

            <td style="text-align: right;font-size: 1.091em;padding-right:5px;"> 説明</td>

            <td colspan="2"><textarea cols="70" rows="6" name="jform[QUES_DESCRIPTION]"><?php echo $this->row->QUES_DESCRIPTION;?></textarea></td>

        </tr>

         <tr>

            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">必須<span style="color: red;font-size: small;font-family: 'ＭＳ Ｐゴシック', Osaka;">※</span></td>

            <td colspan="2">

                <select id="" name="jform[QUES_REQUIRED]" class="big">

                    <?php 

                        if($this->row->QUES_REQUIRED == 0){

                            echo '<option selected value="0">回答必要ない</option>

                                    <option value="1">回答必要</option>';

                        } 

                        else{

                            echo '<option value="0">回答必要ない</option>

                                    <option selected value="1">回答必要</option>';

                        }

                    ?>

                </select> 

            </td>			

        </tr>

        <tr>

            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">タイプ<span style="color: red;font-size: small;font-family: 'ＭＳ Ｐゴシック', Osaka;">※</span></td>

            <td colspan="2">

                 <select id="type" name="jform[QUES_TYPE]" class="big">

                    <option value="0">--選択種類を選択してください--</option>

                    <?php 

                        if($this->row->QUES_TYPE == 1){

                            echo '<option selected value="1">複数回答可</option>

                                <option value="2">単一回答</option>

                                <option value="3">自由回答</option>';

                        } 

                        elseif($this->row->QUES_TYPE == 2){

                            echo '<option value="1">複数回答可</option>

                                <option selected value="2">単一回答</option>

                                <option value="3">自由回答</option>';

                        }

                        elseif($this->row->QUES_TYPE == 3){

                            echo '<option value="1">複数回答可</option>

                                <option value="2">単一回答</option>

                                <option selected value="3">自由回答</option>';

                        }

                    ?>

                 </select>

            </td>

        </tr>

        <tr id="note">

            <td style="text-align: right;font-size: 1.091em;padding-right:5px;"> 

                回答の選択肢

                </td>

            <td>

                <?php 

                    $model = $this->getModel();

                    $ansq = $model->loadANSQ($this->row->QUES_CODE); //Lay ANSQ theo QUES_CODE

                    if($ansq != null){

                        $str = '';

                        foreach($ansq as $value) {

                            $str .= $value->ANSQ_VALUE."\n";

                        }

                        echo "<textarea id='value' cols='70' rows='6' name='jform[ANSQ_VALUE]'>$str</textarea>";

                    }

                ?>

            </td>

            <td><label style="font-size: 1.091em;color: #000099;">(選択肢を箇条書きで入力してください)</label></td>

        </tr>

        <!-- <tr>

            <td style="text-align: right;font-size: 1.091em;padding-right:5px;">公開/非公開</td>

            <td colspan="2">

                <select id="" name="jform[QUES_PUBLISHED]" class="inputbox big">

                    <?php 

                        if($this->row->QUES_PUBLISHED == 1){

                            echo '<option selected value="1">公開 </option>

                                <option value="0">非公開 </option>';

                        } 

                        else{

                            echo '<option value="1">公開 </option>

                                <option selected value="0">非公開 </option>';

                        }

                    ?>

                </select>

            </td>

        </tr> -->

     </table>



   <input type="hidden" name="task" value=""/>

</form>

 <script>

 jq(document).ready(function(){    

        update_select();

		jq("#serq").change(function(){

		  update_select();

			

		});

        

        //document.getElementById('note').style.display='none';

        jq("#type").change(function(){

			var id = document.getElementById("type").value;

            

            if(id === '1' || id === '2'){

                //document.getElementById('note').style.display='';

                jq("#note").show('normal');

            }

            else{

                //document.getElementById('note').style.display='none';

                jq("#note").hide('normal');

                jq('#value').val("");

            }

		});

 	});

 function update_select(){
    var id = document.getElementById("serq").value;

    var url = "index.php?top=page&option=com_question&task=selectSERQ&SERQ_CODE="+id;

    

    jq.get(url, function(data) {

      jq('#pagq').html(data);

    });
 }

</script>